<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<!-- colum right -->
<div class="middle myclear">
	<div class="pad10">
		<h2 class="marbottom10 martop20">
			<?php echo $tracking_lang['banner_running'];?>
		</h2>
        <br />
		<div class="dashboard-box myclear">					
			<table class="mbd-timebox martop20" cellpadding="0" cellspacing="0" border="0">	
				<tr>
					<td class="padright10 ver-middle">
                    Nhóm : 
						<select class="payment-by-month" id="filterType" onchange="changeType(this.value);">
                            <option value="-1" <?php echo $typegroup==-1 ? 'selected="selected"':'' ;?>><?php echo $tracking_lang['all']?></option>
							<option value="1" <?php echo $typegroup==1 ? 'selected="selected"':'' ;?>><?php echo $tracking_lang['internal']?></option>
							<option value="2" <?php echo $typegroup==2 ? 'selected="selected"':'' ;?>><?php echo $tracking_lang['customer']?></option>
						</select>
					</td>
					<td class="padright10 ver-middle">
                    Groupid : 
                        <span id="typediv">
    						<select class="payment-by-month" id="filterGroup">
                                <option value="-1" <?php echo $groupid==-1 ? 'selected="selected"':'' ;?>><?php echo $tracking_lang['all']?></option>
                                <?php foreach($lstgroupid as $gr){ ?>
        							<option value="<?php echo $gr['groupid']; ?>" <?php echo $groupid==$gr['groupid'] ? 'selected="selected"':'' ;?>><?php echo $gr['groupname']; ?></option>
        						<?php } ?>
                            </select>
                        </span>
					</td>
                    <td class="padright10 ver-middle">
                    Typeview : 
                        <span id="typediv">
    						<select class="payment-by-month" id="filterTypeView">
                                <option value="2" <?php echo $typeview==2 ? 'selected="selected"':'' ;?>><?php echo $tracking_lang['all']?></option>
                                <option value="1" <?php echo $typeview==1 ? 'selected="selected"':'' ;?>>Đã phân zone</option>
                                <option value="3" <?php echo $typeview==3 ? 'selected="selected"':'' ;?>>Chưa phân zone</option>
                            </select>
                        </span>
					</td>
					<td class="padright10 ver-middle">
                        Tìm kiếm : 
						<input type="text" id="txtSearch" value="<?php echo $key;?>"/>
					</td>
                    <td class="ver-middle">
                        <input type="button" class="btn" value="Xem" id="search"/>
                    </td>
				</tr>
			</table>
			<div id="campaigndiv">
				<table class="tbl-list" width="100%" cellpadding="0" cellspacing="0" border="1" id="table">
	                <thead>
						<tr>
                            <th class="td-label bold text-center ver-middle" width="50" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['stt'];?></span>
							</th>
							<th class="td-label bold text-center ver-middle" width="50" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['username'];?></span>
							</th>
							<th class="td-label bold text-center ver-middle" width="155" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['banner'];?></span>
							</th>
                            <th class="td-label bold text-center ver-middle" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['location'];?></span>
							</th>
							<th class="td-label bold text-center ver-middle" style="padding: 5px 0;">
	                            <span><?php echo $tracking_lang['w'];?></span>
							</th>
                            <th class="td-label bold text-center ver-middle" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['balance'];?></span>
							</th>
                            <th class="td-label bold text-center ver-middle" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['promotions'];?></span>
							</th>
                            <th class="td-label bold text-center ver-middle" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['budget'];?></span>
							</th>
							<th class="td-label bold text-center ver-middle" style="padding: 5px 0;">
								<span><?php echo $tracking_lang['speed'];?></span>
							</th>
						</tr>
	                </thead>
	                <tbody>
					<?php $index=1+($page-1)*$rownum;
                    foreach($info as $if){ ?>
                    <tr>
                        <td>
                            <p class="pad5 text-center">
                                <?php echo $index;?>
                            </p>
						</td>
						<td>
                            <?php echo $if['username'];?>
						</td>
						<td>
                            <div class="db-list-cl-banner">
								<p>
                                    <a href="<?php echo site_url('tracking').'/zone?bannerid='.$if['bannerid'];?>">
									   <?php echo $if['bannername'];?>
                                    </a>
								</p>
								<p>
                                    <a href="<?php echo site_url('monitor').'/campaignInQueueMonitoring/?campaignid='.$if['campaignid'].'&campaignname='.$if['campaignname'];?>">
									   <span class="text-999"><?php echo $if['campaignname'];?></span>
                                    </a>
								</p>
							</div>
                        </td>
						<td>
                            <p class="pad5">
								<?php $mystring =$if['lstlocation'];
                                if(strpos($mystring,0)==false)
                                {
                                    $mystring = str_replace('0',$tracking_lang['toanquoc'],$mystring);
                                }
                                if(strpos($mystring,1)==false)
                                {
                                    $mystring = str_replace('1',$tracking_lang['bac'],$mystring);
                                }
                                if(strpos($mystring,2)==false)
                                {
                                    $mystring = str_replace('2',$tracking_lang['trung'],$mystring);
                                }
                                if(strpos($mystring,3)==false)
                                {
                                    $mystring = str_replace('3',$tracking_lang['nam'],$mystring);
                                }
                                echo $str= rtrim($mystring,',');
                                ?>
							</p>
                        </td>
						<td>
                            <?php echo number_format($if['w']);?>
                        </td>
                        <td>
                            <?php echo number_format($if['balance']);?>
                        </td>
                        <td>
                            <?php echo number_format($if['promotions']);?>
                        </td>
                        <td>
                            <?php if($if['typebudget']==1){ ?>
                                <div id="divBudget">
                                    <span id="editBudget"><?php echo number_format($if['maxValueDay'])?>(VND)</span>
                                    <p class="text-999">Theo ngày</p>
                                </div>
                            <?php }else{ ?>
                                <div id="divBudget">
                                    <span id="editBudget"><?php echo number_format($if['ExpireValue'])?>(VND)</span>
                                    <p class="text-999">Theo chiến dịch</p>
                                </div>
                            <?php } ?>
                        </td>
						<td>
                            <?php echo $if['speed'];?>
                        </td>
					</tr>
					<?php $index++;
                    } ?>	
	                </tbody>
				</table>
                
                <table class="tbl-list brv-paging martop10 float-right" border="1" cellpadding="0" cellspacing="0">
					<tr>
						<td class="brv-paging-name">
                            <?php echo $tracking_lang['page'];?> : <?php echo $page;?> / <?php echo $totalpage;?></td>
						<td class="brv-paging-pre-next" width="48">
							<img class="brv-img-pre" alt="previous" src="/images/imgpre.gif" <?php echo ($page > 1) ? 'onclick="campPaging(\'' . site_url("tracking/trackingBannerRunning?page=".($page-1)."&rownum=".$rownum).'\');"' : ''; ?>/>
							<img class="brv-img-next" alt="next" src="/images/imgnext.gif" <?php echo ($page < $totalpage) ? 'onclick="campPaging(\'' . site_url("tracking/trackingBannerRunning?page=".($page+1)."&rownum=".$rownum).'\');"' : ''; ?>/>
						</td>
						<td class="brv-paging-num-item">
							<select id="slcNumItem" onchange="campPaging('<?php echo site_url("tracking/trackingBannerRunning?page=1&rownum="); ?>' + this.value);">
								<option value="10" <?php echo ($rownum == 10) ? 'selected="selected"' : '';?>>10</option>
								<option value="20" <?php echo ($rownum == 20) ? 'selected="selected"' : '';?>>20</option>
								<option value="50" <?php echo ($rownum == 50) ? 'selected="selected"' : '';?>>50</option>
							</select>
						</td>
                        <td class="brv-paging-pre-next">
							<a <?php echo 'onclick="campPaging(\'' . site_url("tracking/trackingBannerRunning?page=1&rownum=".($rownum*$totalpage)).'\');"'; ?>>all</a>
						</td>
					</tr>
				</table>
			</div>	
		</div>
		<br />
        <br />
        <br />
        <br />
        <br />
	</div> 
</div>
<script type="text/javascript">
    function changeType(value){
        var success = function(data)
        {
        	$('#typediv').html(data);
        };
        var strURL = "<?php echo site_url('tracking').'/getGroupByType?value='?>"+value;
        getAjax(strURL,"",'', '', '', false, success);
    }
    function campPaging(url)
	{
        var txtSearch = $('#txtSearch').val();
        var filterType = $('#filterType').val();
        var filterGroup = $('#filterGroup').val();
        url = url+'&typegroup='+filterType+'&groupid='+filterGroup+'&key='+txtSearch;
		window.location = url;
		return;
	}
    $('#search').click(function() {
        var txtSearch = $('#txtSearch').val();
        var filterType = $('#filterType').val();
        var filterGroup = $('#filterGroup').val();
        var filterTypeView = $('#filterTypeView').val();
        url= '<?php echo site_url('tracking').'/trackingBannerRunning?typegroup='?>'+filterType+'&groupid='+filterGroup+'&typeview='+filterTypeView+'&key='+txtSearch;
        window.location=url;
    });
</script>